/* 
 * Đoạn Script giúp tạo kịch bản các bước
 * Trước khi dùng phải load file: jquery.stepy.min.js
 */

//********* WIZARD **************//
$(document).ready(function () {

    $('#default').stepy();

    $('#custom').stepy({
        backLabel: 'Backward',
        block: true,
        errorImage: true,
        nextLabel: 'Forward',
        titleClick: true,
        validate: true
    });

    $('div#step').stepy({
        finishButton: false
    });

    // Optionaly
    $('#custom').validate({
        errorPlacement: function (error, element) {
            $('#custom div.stepy-error').append(error);
        },
        rules: {
            'user': {
                maxlength: 1
            },
            'email': 'email',
            'checked': 'required',
            'newsletter': 'required',
            'password': 'required',
            'bio': 'required',
            'day': 'required'
        },
        messages: {
            'user': {
                maxlength: 'User field should be less than 1!'
            },
            'email': {
                email: 'Invalid e-mail!'
            },
            'checked': {
                required: 'Checked field is required!'
            },
            'newsletter': {
                required: 'Newsletter field is required!'
            },
            'password': {
                required: 'Password field is requerid!'
            },
            'bio': {
                required: 'Bio field is required!'
            },
            'day': {
                required: 'Day field is requerid!'
            },
        }
    });

    $('#callback').stepy({
        back: function (index) {
            alert('Going to step ' + index + '...');
        },
        next: function (index) {
            if ((Math.random() * 10) < 5) {
                alert('Invalid random value!');
                return false;
            }

            alert('Going to step ' + index + '...');
        },
        select: function (index) {
            alert('Current step ' + index + '.');
        },
        finish: function (index) {
            alert('Finishing on step ' + index + '...');
        },
        titleClick: true
    });

    $('#target').stepy({
        description: false,
        legend: false,
        titleClick: true,
        titleTarget: '#title-target'
    });

});